const img = new File();
// 拿到图片的objecturl
const imgUrl = URL.createObjectURL(img);
const imgDom = document.createElement('img');
imgDom.src = imgUrl;
let data = null;
imgDom.onload = () => {
    const canvas = document.createElement('canvas');
    const context = canvas.getContext('2d');
    canvas.width = imgDom.clientWidth;
    canvas.height = imgDom.clientHeight;
    context.drawImage(imgDom, 0, 0);
    data = canvas.toDataURL('image/jpeg', 0.7)
}